<template>
  <uni-page-wrapper>
    <uni-page-body>
      <uni-view  class="paddingView">
		  <uni-view class="have" v-if="total_usercount>1">
			<uni-view class="table">
			  <uni-view class="item">
				<uni-view class="t">
					{{$t("team.Total assets")}}
				</uni-view>
				  <uni-view class="b">
					{{total_money}}
				  </uni-view>
			  </uni-view>
			  <uni-view class="item">
				<uni-view class="t">
					{{$t("team.Total commission")}}
				</uni-view>
				  <uni-view class="b">
					{{total_detail}}
				  </uni-view>
			  </uni-view>
			  <uni-view class="item">
				<uni-view class="t">
					{{$t("team.Total deposit")}}
				</uni-view>
				  <uni-view class="b">
					{{total_amount}}
				  </uni-view>
			  </uni-view>
			  <uni-view class="item">
				<uni-view class="t">
					{{$t("team.Total withdrawal")}}
				</uni-view>
				  <uni-view class="b">
					{{total_withdrawal}}
				  </uni-view>
			  </uni-view>
			  <uni-view class="item">
				<uni-view class="t">
					{{$t("team.total people")}}
				</uni-view>
				  <uni-view class="b">
					{{total_usercount}}
				  </uni-view>
			  </uni-view>
			  <uni-view class="item">
				<uni-view class="t">
					{{$t("team.Added today")}}
				</uni-view>
				  <uni-view class="b">
					{{today_count}}
				  </uni-view>
			  </uni-view>
			  <uni-view class="item">
				<uni-view class="t">
					{{$t("team.My total income")}}
				</uni-view>
				  <uni-view class="b">
					{{total_revenue}}
				  </uni-view>
			  </uni-view>
			  <uni-view class="item">
				<uni-view class="t">
					{{$t("team.My profit today")}}
				</uni-view>
				  <uni-view class="b">
					{{today_revenue}}
				  </uni-view>
			  </uni-view>
			</uni-view>  
			
			<uni-scroll-view  class="nav">
			  <div class="uni-scroll-view">
			    <div class="uni-scroll-view" style="overflow: auto hidden">
			      <div class="uni-scroll-view-content">
					  <uni-view :class="pick ==item.level ?'item act':'item'" v-for="item in levels" :key="item.level" @click="chose(item.level)">{{item.title}}</uni-view>
					</div>
			    </div>
			  </div>
			</uni-scroll-view>
			<uni-view  class="list"> 
				<uni-view class="item" v-for="item in showList" :key="item.level">
					<uni-view class="top">
						<uni-view class="left">
							{{$t("team.Username")}}：{{item.username}}
						</uni-view>
					</uni-view>
					<uni-view class="top">
						<uni-view class="left">
							{{$t("team.Tel")}}：{{item.tel}}
						</uni-view>
					</uni-view>
					<uni-view class="top">
						<uni-view class="left">
							{{$t("team.Balance")}}：{{item.money}}
						</uni-view>
					</uni-view>
					<uni-view class="bottom">
						<uni-view class="left">
							{{$t("team.Register time")}}：{{item.time}}
						</uni-view>
					</uni-view>
					<uni-view class="submit">
						<uni-view class="btn" @click="team(item.id)">
							{{$t("team.Team list")}}
						</uni-view>
						<uni-view class="btn" @click="income(item.id)">
							{{$t("team.Income list")}}
						</uni-view>
					</uni-view>
				</uni-view>
			</uni-view>
		  </uni-view>
        <uni-view  class="none" v-else>
          <uni-image  class="noneImg">
            <div
              :style="getImg()"
            >
            </div>
            <img src="/static/img/notList.7ca9007a.png" />
          </uni-image>
        </uni-view>
      </uni-view>
    </uni-page-body>
  </uni-page-wrapper>
</template>

<script>
	import service from '@/store/service.js'
	export default {
		data() {
			return {
				total_usercount:1,
				total_money:'',
				total_detail:'',
				total_amount:'',
				total_withdrawal:'',
				total_revenue:'',
				today_revenue:'',
				today_count:'',
				pick:0,
				levels:[],
				showList:[]
			}
		},
		mounted() {
			service.auth(this,service.api.app_getagency,{},function(self,res){
				self.total_usercount = res.total_usercount?res.total_usercount:0
				self.total_money = res.total_money?res.total_money:0
				self.total_detail = res.total_detail?res.total_detail:0
				self.total_amount = res.total_amount?res.total_amount:0
				self.total_withdrawal = res.total_withdrawal?res.total_withdrawal:0
				self.total_revenue = res.total_revenue?res.total_revenue:0
				self.today_revenue = res.today_revenue?res.today_revenue:0
				self.today_count = res.today_count?res.today_count:0
				var levels = []
				res.data.forEach(function(e){
					var hasLevel = false
					var items = []
					items.push(e)
					for(var i in levels){
						if(levels[i].title == e.level){
							hasLevel = true
							levels[i].items.push(e)
						}
					}
					if(!hasLevel){
						levels.push({level:e.lvid,title:e.level,items:items})
					}
				})
				self.levels = levels
				self.pick = levels[0].level
				self.showList = levels[0].items
			})
		},
		methods: {
			getImg() {
				return this._i18n.locale == "en" ?
					"background-image: url('/static/img/notList.7ca9007a.png');background-position: 0% 0%;background-size: 100% 100%;background-repeat: no-repeat;" :
					"background-image: url('/static/notList.7ca9007a.png');background-position: 0% 0%;background-size: 100% 100%;background-repeat: no-repeat;";
			},
			chose(level){
				this.pick = level
				for(var i in this.levels){
					if(this.levels[i].level == level){
						this.showList = this.levels[i].items
					}
				}
			},
			income(id){
				uni.navigateTo({
					url:'/pages/team/income?id='+id
				})
			},
			team(id){
				uni.navigateTo({
					url:'/pages/team/other?id='+id
				})
			}
		}
	}
</script>

<style>
@import url(./team.css);
</style>